﻿using System;
using System.Windows;

namespace SStuff.FlowControls
{
    /// <summary>
    /// Represent a layout algorithm acting on IFlowItem2D items
    /// </summary>
    public interface IFlowLayout2DAlgorithm
    {
        /// <summary>
        /// Set the size of the layout viewport
        /// </summary>
        /// <param name="availableSize"></param>
        void SetAvailableSize(Size availableSize);

        /// <summary>
        /// Get the maximum item count displayable correctly with the current algorithm
        /// </summary>
        /// <returns></returns>
        int GetMaxDisplayedItems();

        /// <summary>
        /// Compute the layout of an item
        /// </summary>
        /// <param name="normalizedOffset">[(-1) - (+1)]</param>
        /// <param name="item">Item to layout</param>
        /// <param name="consideredItemsCount">Number of displayed items at the current frame</param>
        void ComputeLayout(double normalizedOffset, IFlowItem2D item, int consideredItemsCount);       

        /// <summary>
        /// Get a value indicating if the algorithm supports gestures
        /// </summary>
        bool SupportsGestures { get; }

        /// <summary>
        /// Get the normalized index corresponding to the contact position
        /// </summary>
        /// <param name="contactPosition"></param>
        /// <returns></returns>
        double GetNormalizedOffsetAtPoint(Point contactPosition);

        /// <summary>
        /// Raised when the algorithm want to invalidate the current layout
        /// </summary>
        event EventHandler LayoutChanged;
    }
}
